package com.datamining.rec_test

/**
  * Created by Administrator on 2017/3/11.
  */
/**
  * spark-test
  * DataTypeTest
  *
  * @author Administrator kevin
  **/
object DataTypeTest {

  def main(args: Array[String]): Unit = {

//    println("============= vector ==========================================")
//    val dv: Vector = Vectors.dense(1.2, 2.3, 3.5);
//    println(dv)
//
//    val sv1: Vector = Vectors.sparse(3, Array(0, 2), Array(1.0, 3.0))
//    println(sv1)
//
//    val sv2: Vector = Vectors.sparse(3, Seq((0, 1.0), (2, 3.0)))
//    println(sv2)
////    println(sv2.apply(0))
//
//
//    println("============== labledPoint =========================================")
//
//    val  pos = LabeledPoint(1.0, Vectors.dense(1.0, 2.0, 3.0));
//    println(pos)
//
//    val neg = LabeledPoint(0.0, Vectors.sparse(3, Array(0, 2), Array(1.0, 3.0)))
//    println(neg)
//
//    println("============== local matrix =========================================")
//    // Create a dense matrix ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0))
//    val dm: Matrix = Matrices.dense(3, 2, Array(1.0, 3.0, 5.0, 2.0, 4.0, 6.0))
//    println(dm)
//
//    // Create a sparse matrix ((9.0, 0.0), (0.0, 8.0), (0.0, 6.0))
//    val sm: Matrix = Matrices.sparse(3, 2, Array(0, 1, 3), Array(0, 2, 1), Array(9, 6, 8))
//    println(sm)
//
//
//    println("============== distributed matrix =========================================")
//    val sparkConf = new SparkConf();
//    sparkConf.setMaster("local[4]"); // 本地模式
//    sparkConf.setAppName("my_test");
//
//    val sparkContext = new SparkContext(sparkConf);
//
//    val rows: RDD[Vector] =  sparkContext.parallelize(Seq(dv));// an RDD of local vectors
//    // Create a RowMatrix from an RDD[Vector].
//    val mat: RowMatrix = new RowMatrix(rows)
//
//    // Get its size.
//    val m = mat.numRows()
//    val n = mat.numCols()
//
//    // QR decomposition
//    val qrResult = mat.tallSkinnyQR(true)
//
//    println(m)
//    println(n)

    var li: List[Int] = List(1);
    li = li.:+(2)
    li = li.::(0)


    for(a <- li){
      println(a)
    }

    li = li.map(a => a*a)

    for(a <- li){
      println(a)
    }

  }
}
